package com.kefu.exam.vo;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractInsertVo;
import com.kefu.exam.model.ExamSubject;
import cn.hutool.core.util.IdUtil;
import com.kefu.exam.model.ExamSubjectAnswer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.List;

/**
 * @author xy
 * @date 2022/02/28
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(description = "考题表")
public class ExamSubjectInsertVo extends AbstractInsertVo<ExamSubject> {

    @ApiModelProperty(value = "问题ID")
    private String subjectId;

    @NotEmpty
    @ApiModelProperty(value = "分类")
    private String typeId;

    @ApiModelProperty(value = "分类名")
    private String typeName;

    @ApiModelProperty("分析内容")
    private String subjectContent;

    @ApiModelProperty("试题答案")
    private List<ExamSubjectAnswer> examSubjectAnswerList;



    @Override
    public ExamSubject convert() {
        ExamSubject info = new ExamSubject();
        info.setSubjectId(IdUtil.simpleUUID());
	    info.setTypeId(typeId);
	    info.setTypeName(typeName);
        info.setSubjectContent(subjectContent);
        KefuContext context = KefuContext.getKefuContext();
        info.setCreateTime(context.getNow());
        info.setCreateUser(context.getUserId());
        info.setCreateName(context.getUserName());
        info.setUpdateTime(context.getNow());
        info.setUpdateUser(context.getUserId());
        info.setUpdateName(context.getUserName());
        info.setTenantId(context.getTenantId());
        return info;
	}
}